package com.huanuo.internetofthings.service.user;

import com.huanuo.internetofthings.bo.userCredentials.UserCredentials;
import com.huanuo.internetofthings.dao.userCredentials.UserCredentialsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.unicorn.framework.base.base.AbstractService;
import org.unicorn.framework.core.SysCode;
import org.unicorn.framework.core.exception.PendingException;

@Service
public class UserCredentialsService extends AbstractService {

	@Autowired
	private UserCredentialsMapper userCredentialsMapper;

	public UserCredentials addUserCredentials(UserCredentials userCredentials) throws PendingException {
		try {
			this.userCredentialsMapper.insert(userCredentials);
			return userCredentials;
		} catch (Exception e) {
			error("新增用户凭证信息", e);
			throw new PendingException(SysCode.DB_ERROR, "新增用户凭证信息");
		}
		
	}

	public UserCredentials getUserCredentials(UserCredentials userCredentials) throws PendingException {
		try {
			return this.userCredentialsMapper.selectOne(userCredentials);
		} catch (Exception e) {
			error("获取用户凭证信息失败", e);
			throw new PendingException(SysCode.DB_ERROR, "获取用户凭证信息失败");
		}
		
	}
}